#ifndef ELEMENTDOOR_H
#define ELEMENTDOOR_H

#include "GameElement.h"
#include "Drawing.h"
#include "AnimationObj.h"

struct doorAnimation: public animationObj{


    doorAnimation(){

    }

    void render(){
        static GLuint dlID=0;
        glPushMatrix();
        glRotatef(90. * (float)frame/maxframe,0,1,0);

        if(!dlID){

        dlID=glGenLists(1);
        glNewList(dlID,GL_COMPILE_AND_EXECUTE);
        glColor3f(0.4,0.3,0);
        Drawing::drawCuboid(vector3<float>(0,0,0),vector3<float>(1,2,0.4));
        glEndList();

        }else glCallList(dlID);

        glPopMatrix();

        nextFrame();

    }
};

class ElementDoor:virtual public GameElement
{
    doorAnimation aniDoor;
    bool faceSide;
public:
    ElementDoor(vector3<int> pos);
    void invokeCollisionEvent(Character*);
    void invokeActivateEvent();
    void invokeUpdateEvent(Character *);
    void activate();
    void deactivate();
    void render();
    void editorModeRender(){render();}
    const char* getName(){return "Door";}

    void setFaceSide(bool _faceSide){faceSide=_faceSide;}
    bool getFaceSide(){return faceSide;}
};

#endif // ELEMENTDOOR_H
